Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPS/TST: tzdata is optional, not required #47467

Merged
merged 17 commits into from
Aug 12, 2022

Conversation

lithomas1
Copy link
Member

@lithomas1 lithomas1 marked this pull request as ready for review June 22, 2022 19:43
@lithomas1
Copy link
Member Author

OK, this works now. We should probably specify a minimum tzdata version too, though.

@jbrockmendel Do you have anything in mind?

@jbrockmendel
Copy link
Member

no idea, cc @pganssle ?

@jreback
Copy link
Contributor

jreback commented Jun 22, 2022

seems fine, does this need backport?

@jreback jreback added Timezones Timezone data dtype Dependencies Required and optional dependencies labels Jun 22, 2022
@mroeschke
Copy link
Member

We should probably specify a minimum tzdata version too, though.

My 2c is might as well have the min version be the latest available version since this is a new feature.

does this need backport?

Don't think so since ZoneInfo support will be new for 1.5.

@simonjayhawkins
Copy link
Member

does this need backport?

Don't think so since ZoneInfo support will be new for 1.5.

correct. the failures were only on nightlies (main). 1.4.x is passing tests (or was when I last run the build test which is running again now ready for release MacPython/pandas-wheels#173)

@simonjayhawkins simonjayhawkins added this to the 1.5 milestone Jun 22, 2022
@lithomas1
Copy link
Member Author

Zoneinfo is also kinda wonky, since it doesn't really need the tzdata package, just a copy of the IANA tz database. I'm not sure we have a way to check the version of the IANA tz database, though.

@lithomas1 lithomas1 mentioned this pull request Jun 23, 2022
5 tasks
@mroeschke
Copy link
Member

Zoneinfo is also kinda wonky, since it doesn't really need the tzdata package, just a copy of the IANA tz database. I'm not sure we have a way to check the version of the IANA tz database, though.

I don't think we should necessarily runtime check tzdata in pandas, but it would be good to state that the minimum version we test with tzdata=2022.1

@lithomas1
Copy link
Member Author

This is blocking #47442, so we should probably merge this now, and open an issue to discuss tzdata version, since there is not yet enough consensus on that.

pandas/conftest.py Outdated Show resolved Hide resolved
@mroeschke
Copy link
Member

IMO setting tzdata=2022.1 should be okay for now.

lithomas1 and others added 3 commits July 29, 2022 08:07
try:
# py39+
import zoneinfo
from zoneinfo import ZoneInfo
import_optional_dependency("tzdata", errors="raise", min_version="2022.1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC we should only check tzdata if the user doesn't have an OS that already has system timezones that are available.

import zoneinfo
from zoneinfo import ZoneInfo
try:
    ZoneInfo("UTC")
except zoneinfo.ZoneInfoNotFoundError:
    import_optional_dependency("tzdata", errors="warn", min_version="2022.1")

Also I think errors="warn" since tzdata is still optional, and the user may not necessarily use ZoneInfo objects when using pandas (since it's not the default yet)

@lithomas1 lithomas1 mentioned this pull request Jul 30, 2022
4 tasks
@lithomas1
Copy link
Member Author

OK, so I've updated this PR again. It's too difficult/costly to check the version of the system IANA tz db if present, so we're just going to specify a minimum version.

If tzdata is installed, though, the minimum version will be enforced through a warning, even if they have an up to date IANA tz db, since we would want to warn them of the mismatch.

@pep8speaks
Copy link

pep8speaks commented Aug 5, 2022

Hello @lithomas1! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-08-09 13:55:50 UTC

Dependency Minimum Version Notes
========================= ========================= =============================================================
tzdata 2022.1(pypi)/ Allows the use of ``zoneinfo`` timezones with pandas.
2022a(for system tzdata) **Note**: You only need to install the pypi package, if your
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the 2022a is a conda forge package?
https://anaconda.org/conda-forge/tzdata
https://github.com/eggert/tz

Which is a different project from tzdata (2022.1).
https://pypi.org/project/tzdata/#history
https://github.com/python/tzdata

I'm not sure it's a good idea to recommend 2 differently maintained packages here. Can we just recommend the pypi one since it's the once recommended in the official docs https://docs.python.org/3/library/zoneinfo.html#data-sources?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd still want to state a min version for system tzdata for consistency. 2022a is also the version of the actual IANA tz db(it's python's tzdata versioning scheme that's different).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay sounds reasonable then. Might be good then to mention that the system tzdata can be updated by installing the conda forge package?

@lithomas1 lithomas1 requested a review from jreback August 10, 2022 20:04
@lithomas1
Copy link
Member Author

I'm going to self merge this in a couple of days if no other comments, so we can get the Python 3.11 testing in.

@jreback jreback merged commit 1ab02e4 into pandas-dev:main Aug 12, 2022
@jreback
Copy link
Contributor

jreback commented Aug 12, 2022

thanks @lithomas1 this is great

@lithomas1 lithomas1 deleted the fix-tzdata-checking branch August 12, 2022 00:45
YYYasin19 pushed a commit to YYYasin19/pandas that referenced this pull request Aug 23, 2022
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dependencies Required and optional dependencies Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TST: tzdata is a required dependency when testing
6 participants